﻿<%@ Page Title="" Language="C#" MasterPageFile="~/UserControl/UI/MainSite.Master" AutoEventWireup="true" CodeBehind="UpdateTel.aspx.cs" Inherits="UI.Module.User.UpdateTel" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
        <script type="text/javascript" src="/js/Data.js"></script>
         <script type="text/javascript">
             var tel = "<%=username.ClientID %>";
             var yz = "<%=captcha.ClientID %>";
             var btn = "<% =btnSet.ClientID %>";
             //手机号
             var str17 = /^1[3|4|5|8][0-9]\d{8}$/;
             //验证手机
             function Check_CaptainTel() {
                 var captainTel = $("#"+tel).val();
                 if (captainTel == "" || captainTel == "请输入手机号") {
                     $(".tips").html("请输入手机号");
                     return false;
                 } else {
                     //alert(legal.length);
                     if (str17.test(captainTel)) {
                         return true;
                     } else {
                        $(".tips").html("请输入有效手机号！");
                         return false;
                     }
                 }
             }
             //验证码验证
             function Check_Code() {
                 var code = $("#" + yz).val();
                 if (code == "" || code == "请输入验证码") {
                       $(".tips").html("请输入验证码");
                     return false;
                 } else {
                     //alert(legal.length);
                     if (code.length = 6) {
                         return true;
                     } else {
                        $(".tips").html("请输入有效验证码！");
                         return false;
                     }
                 }
             }

             function getCaptcha(obj) {
                 var _self = obj;
                 _self.disabled = true;
                 if (!Check_CaptainTel()) {
                     _self.disabled = false;
                     return false;
                 }
                 $.ajax({
                     type: "POST",
                     url: "../../GetPwd.aspx",
                     data: "type=getpwd&yz=no&phone=" + $("#"+tel).val(),
                     success: function (msg) {
                         if (msg == -1) {
                             $(".tips").html("验证码发送成功！");
                             var index = 60;
                             var timer;
                             timer = setInterval(function () {
                                 if (index >= 1) {
                                     $(_self).val(index + "秒后重新获取");
                                     index--;
                                 } else {
                                     $(_self).val("获取手机验证码");
                                     window.clearInterval(timer);
                                     _self.disabled = false;
                                 }
                             }, 1000);
                         } else if (msg == 0) {
                             $(".tips").html("获取失败，请重新获取！");
                             _self.disabled = false;
                         } else if (msg == -100) {
                             $(".tips").html("手机号不存在！");
                             _self.disabled = false;
                         } else if (msg == -200) {
                             $(".tips").html("该账号状态异常！");
                             _self.disabled = false;
                         } else {
                             $(".tips").html("未知错误！");
                             _self.disabled = false;
                         }
                     },
                     error: function () { $(".tips").html("网络有误,请重新获取！"); _self.disabled = false; return false; }
                 });
             }
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <style>
        .input_name {height: 23px; line-height: 23px; border-radius: 3px; border: 1px solid #ccc; padding-left:5px;}
        .input_capt {height: 23px; line-height: 23px; border-radius: 3px; border: 1px solid #ccc; padding-left:5px;}
        .button_captcha {width: 120px; height: 23px; line-height: 23px; border: 1px solid #ccc; border-radius: 3px; cursor: pointer; background: rgb(54,143,223);color: white; border: none;}
        .input_submit_btn {width: 150px; height: 30px; line-height: 30px; border: 1px solid #ccc; border-radius: 3px; cursor: pointer; position: absolute; left: 150px; top: 10px; background: rgb(54,143,223);color: white;}
        .tips {position: absolute; left: 310px; top: 20px; height: 22px; line-height: 22px; color:red;}
    </style>
    <form id="form1" runat="server">
        <h2 class="mbx">我的信息 &gt;修改<asp:Label ID="Label2" runat="server" Text="Label"></asp:Label>的手机号 </h2>
        <div class="cztable">
            <table border="0" cellspacing="0" cellpadding="0" width="500px" style="margin:30px auto 0px auto;">
                <tbody>
                 <tr align="center">
                    <td colspan="2" style="text-align:center;">
                        <span class="span1">请输入<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>的手机号,并修改其联系方式</span>
                    </td>
                </tr>
                <tr align="center">
                    <th style="width:20%; text-align:left;">手机号：</th>
                    <td style="width:70%; text-align:left;"> <input class="input_name" name="username" id="username" maxlength="11" runat="server" value="请输入手机号" autocomplete="off" /></td>
                </tr>
                <tr align="center">
                    <th style="width:20%; text-align:left;">验证码：</th>
                    <td style="width:70%; text-align:left;"><input class="input_capt" name="captcha" id="captcha" runat="server" maxlength="6" value="请输入验证码" autocomplete="off" />
                        <input type="button" value="获取手机验证码" class="button_captcha" onclick="getCaptcha(this);" /></td>
                </tr>
                <tr>
                <td colspan="2" style="text-align:center; position:relative;height: 36px;">
                    <asp:Button class="input_submit_btn" ID="btnSet" Style="border: 0px" Text="修改联系方式" runat="server" OnClick="btnSet_Click" />
                    <p class="tips" id="tips" runat="server"></p>
                </td>
                </tr>
            </tbody></table>
        </div>

    </form>
    <script>
        (function () {
            $("#" + btn).click(function () {
                return Check_CaptainTel();
                return Check_Code();
            });
            $(".input_name").focus(function () {
                var content = $(this).val();
                if (content == "请输入手机号") {
                    $(this).val("");
                }
            }).blur(function () {
                var content = $(this).val();
                if (content == "") {
                    $(this).val("请输入手机号");
                }
            });

            $(".input_capt").focus(function () {
                var content = $(this).val();
                if (content == "请输入验证码") {
                    $(this).val("");
                }
            }).blur(function () {
                var content = $(this).val();
                if (content == "") {
                    $(this).val("请输入验证码");
                }
            });
        })();
    </script>
</asp:Content>
